///import js-src/lib/
///import js-src/com/
qui(function (require, exports, module) {
    Program.Config = $.extend({}, Ancestor.Config, {
        RECOMMEND_RATE: {
          "0": "不推荐", "1": "普通推荐", "2": "重点推荐", "3": "强烈推荐"
        },
        TABLE_COLMODEL_CONFIG: {
            qipuId: {
                name: "qipuId",
                index: 'qipuId',
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.qipuId(v, o, r);
                }
            },
            pname: {
                name: "pname",
                index: 'pname',
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.pname(v, o, r);
                }
            },
            playStatus:{
                name: "playStatus",
                index: 'playStatus',
                title: false,
                width: 80,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.playStatus(v, o, r);
                }
            },
            startPlayTime: {
                name: "startPlayTime",
                index: 'startPlayTime',
                title: false,
                width: 120,
                sortable: false,
                align: "center"
            },
            endPlayTime: {
                name: "endPlayTime",
                index: 'endPlayTime',
                title: false,
                width: 120,
                sortable: false,
                align: "center"
            },
            type: {
                name: "type",
                index: 'type',
                title: false,
                width: 100,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.type(v, o, r);
                }
            },
            bossStatus: {
                name: "bossStatus",
                index: 'bossStatus',
                title: false,
                width: 90,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.bossStatus(v, o, r);
                }
            },
            episodeGrade: {
                //wait to do
                index: "episodeGrade",
                name: "episodeGrade",
                title: false,
                width: 80,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.episodeGrade(v, o, r);
                }
            },
            channelName: {
                name: "channelName",
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.channelName(v, o, r);
                }
            },

            onlineStatus: {
                name: "onlineStatus",
                index: 'onlineStatus',
                title: false,
                width: 80,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.onlineStatus(v, o, r);
                }
            },
            formal: {
                name: "formal",
                index: 'formal',
                title: false,
                width: 80,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.formal(v, o, r);
                }
            },

            updateTime: {
                name: "updateTime",
                index: 'updateTime',
                title: false,
                width: 120,
                sortable: false,
                align: "center"
            },
            operate: {
                name: "operate",
                title: false,
                width: 180,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.operate(v, o, r);
                }
            },
            oaDocEditorStatus: {
                index: 'oaDocEditorStatus',
                name: "oaDocEditorStatus",
                title: false,
                width: 100,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.oaDocEditorStatus(v, o, r);
                }
            },

            operate2: {
                title: false,
                width: 150,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.operate2(v, o, r);
                }
            },
            recommendRate: {
                name: "recommendRate",
                index: 'recommendRate',
                title: false,
                width: 90,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.recommendRate(v, o, r);
                }
            },
            hot: {
                name: "hot",
                index: 'hot',
                title: false,
                width: 130,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.hot(v,o,r);
                }
            },
            test: {
                name: "test",
                index: 'test',
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function(v, o, r) {
                    return Program.Util.formatter.test(v,o,r);
                }
            },
            log_id: {
                name: 'id',
                index: 'id',
                title: false,
                sortable: false,
                hidden: true
            },
            log_addTime:{
                name: 'addTime',
                index: 'addTime',
                sortable: false,
                title: false,
                width: 150,
                align: 'center'
            },
            log_user: {
                name: 'user',
                index: 'user',
                sortable: false,
                title: false,
                width: 150
            },
            log_type: {
                name: 'type',
                index: 'type',
                sortable: false,
                title: false,
                width: 120,
                formatter: function (v, o, r) {
                    return Program.Util.formatter.log_type(v,o, r);
                }
            },
            log_descr: {
                name: "descr",
                index: 'descr',
                title: false,
                width: 450,
                sortable: false
            },
            //'feed_id', "feed_doc", "circle_name" , "event_name" , "uid","operator_user","publish_time"
            feed_id: {
                name: "feedId",
                index: 'feedId',
                title: false,
                width: 70,
                align: "center",
                sortable: false

            },
            feed_doc: {
                name: "description",
                index: 'description',
                title: false,
                width: 120,
                align: "center",
                sortable: false

            },
            circle_name: {
                name: "wallName",
                index: 'wallName',
                title: false,
                width: 200,
                align: "center",
                sortable: false
            },
            event_name: {
                name: "eventName",
                index: 'eventName',
                title: false,
                width: 120,
                sortable: false
            },
            uid: {
                name: "uid",
                index: 'uid',
                title: false,
                width: 70,
                align: "center",
                sortable: false
            },
            operator_user: {
                name: "name",
                index: 'name',
                title: false,
                width: 70,
                align: "center",
                sortable: false
            },
            publish_time: {
                name: "releaseDate",
                index: 'releaseDate',
                title: false,
                width: 120,
                sortable: false,
                align: "center",
                formatter: function (v, o, r) {
                    return Program.Util.formatter.publish_time(v,o, r);
                }
            }
        },
        TABLE_LIBRARY: {
            url: EpgWeb.urlConfig.programList,
            loadBeforeSend: function (xhr, settings) {
                xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                return true;
            },
            rowNum: 40,
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            gridComplete: function () {
                Program.Util.checkPlaying();
            },
            multiselect: false,
            datatype: "local",
            loadtext: '加载中...',
            loadui: "block",
            mtype: "post",
            caption: "节目单列表",
            pager: "#pager",
            colNames: ["奇谱ID", "节目名称", "所属频道", "节目播放状态", "节目状态", "节目类型", "付费状态", "操作","OA审核状态", "节目等级",
                "开始时间", "结束时间", "推荐等级", "是否允许进入热门直播", "是否为测试数据", "是否正式流", "更新日期"],
            colModel: ['qipuId', 'pname', 'channelName', 'playStatus' , 'onlineStatus', 'type', 'bossStatus', "operate", "oaDocEditorStatus","episodeGrade",
                'startPlayTime', 'endPlayTime', "recommendRate", "hot", "test", "formal", 'updateTime']
        },
        TABLE_LIST: {
            url: EpgWeb.urlConfig.programList,
            loadBeforeSend: function (xhr, settings) {
                xhr.setRequestHeader("Sign", "#f93Uc31K24()_@");
                return true;
            },
            loadComplete: function () {
                var jqGridTarget = $("#list");
                var re_records = jqGridTarget.getGridParam('records');
                var parentElement = jqGridTarget.parent();
                var norecordElement = parentElement.find(".norecords")
                if (re_records == 0 || re_records == null) {
                    if (norecordElement.html() == null) {
                        parentElement.append('<div class="norecords">没有符合数据</div>');
                        norecordElement.hide();
                    }
                    norecordElement.show();
                } else {
                    norecordElement.hide();
                }
            },
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            multiselect: false,
            mtype: "post",
            datatype: "local",
            height: 450,
            caption: "节目单列表",
            colNames: ["奇谱ID", "节目名称", "开始时间", "结束时间", "节目类型", "付费状态", "更新日期", "操作"],
            colModel: ["qipuId", "pname", "startPlayTime", "endPlayTime", "type", "bossStatus", "updateTime", "operate2"],
            pager: "#pager",
            toolbar: [true, "top"]
        },

        TABLE_LOG: {
            url: EpgWeb.urlConfig.programLog,
            loadBeforeSend: function (xhr, settings) {
                var auth = Ancestor.Util.getAuth("/program/loglist");
                xhr.setRequestHeader('Sign', auth.sign);
                xhr.setRequestHeader("Time", auth.clientTime);
                xhr.setRequestHeader("From", auth.from);
                return true;
            },
            multiselect: false,
            loadtext: '加载中...',
            loadui: 'block',
            rowNum: 50,
            mtype: "post",
            datatype: "local",
            prmNames: {
                page: "pageNo",
                rows: "pageSize"
            },
            colNames: ["ID", "操作时间", "人员", "动作", "备注"],
            colModel: ['log_id', "log_addTime", "log_user" , "log_type" , "log_descr"],
            pager: "#log_pager"
        },

        TABLE_FEED: {
            localReader: {
                id: "feedId",
                root: "rows",
                page: "page",
                total: "total",
                records: "records"
            },
            multiselect: false,
            datatype: "local",
            loadtext: '加载中...',
            loadui: 'block',
            rowNum: 10,
            colNames: ["feedid", "feed文案", "落地圈子名称", "落地事件", "UID","发布人","发布时间"],
            colModel: ['feed_id', "feed_doc", "circle_name" , "event_name" , "uid","operator_user","publish_time"],
            pager: "#feed_pager",
            onPaging: function (pgButton) {
                var retValue = Program.Util.pageBeanPageHandler("feedList", "feed_pager", Program.Config.PageBeanFeed, pgButton);
                if (retValue != null) {
                    $("#feedList")[0].addJSONData(retValue)
                }
                return "stop";
            }
        },

        WeekManager: null,
        dateTime: null,
        PageBeanFeed:null,
        AUTH_FORCE_CHECK: false,
        AUTH_FEED_VIEW:false,
        AUTH_LOG_DETAIL:false,
        oaTest:false,
        Header:{
            daojuSuggest:["道具渠道号","道具渠道名称","创建时间","创建人"],
            voteSuggest:["投票ID","投票名称","创建时间"],
            puyuSuggest:["条形码","片名","出品方","发行时间","主演 /演唱者","导演","版权方","合同编号","授权起止时间"],
            albumSuggest: ["奇谱ID","显示名称","频道","版权到期时间","是否付费","发布状态"],
            qitanSuggest:["评论ID","评论名称","创建时间"],
            actorSuggest:["人物ID","名称","别名","性别","人物类型","审核状态"],
            playbackSuggest:["节目Id","节目显示名称","频道","发行时间","是否付费","发布状态"]
        },
        EDIT_VALIDATOR: {
            rules: {
                pname:{
                    required:true,

                    maxlength:40
                }
            },
            messages:{

                pname:{
                    required:"节目名称不能为空",
                    maxlength:"节目名称长度不能超过{0}"
                }
            },
            onkeyup: function (element) {
                var $element = $(element);
                var name = $element.attr('name');
                var cb = {
                    onkeyup: true
                };

                if (typeof cb.onkeyup == 'function') {
                    cb.onkeyup($element, this);
                } else if (cb.onkeyup) {
                    $element.valid();
                }
            },
            onfocusout: function (element) {
                var $element = $(element);
                var name = $element.attr('name');
                var cb = {
                    onfocusout: true
                };

                if (typeof cb.onfocusout == 'function') {
                    cb.onfocusout($element, this);
                } else if (cb.onfocusout) {
                    $element.valid();
                }
            }
        }

    })


})